package com.kingyun.gpsinspection.purificationservice.services.iam.taskjobservice;

import com.kingyun.gpsinspection.purificationservice.dao.model.TaskJobInfo;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * Created by yangsy on 2017/3/14.
 */
@Component
public class QuartzJobFactory implements Job {
    @Autowired
    private TaskJobService taskJobService;
    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {

        TaskJobInfo taskJobInfo = (TaskJobInfo) jobExecutionContext.getMergedJobDataMap().get("scheduleJob");
        try {
            //TaskJobService taskJobService = (TaskJobService) Class.forName(taskJobInfo.getPackagePath()).newInstance();
            taskJobService.execute();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
